package cc.minos.servers.openfire.chats
{
	import org.igniterealtime.xiff.core.UnescapedJID;
	import org.igniterealtime.xiff.data.Message;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class ChatMessage
	{
		private var _from:UnescapedJID;
		private var _nick:String;
		private var _body:String;
		private var _time:Date;
		public var local:Boolean;
		public var consecutive:Boolean;
		private var _chat:SimpleChat;
		private var _id:String;
		
		public function ChatMessage( from:UnescapedJID , body:String , nick:String = null , time:Date = null , chat:SimpleChat = null , id:String = null )
		{
			_id = id;
			_from = from;
			_nick = nick;
			_body = body;
			_time = time;
			_chat = chat;
		}
		
		public static function fromMessage( message:Message , chat:SimpleChat , local:Boolean = false ):ChatMessage
		{
			var msg:ChatMessage = new ChatMessage( message.from.unescaped , message.body , message.from.resource , message.time , chat );
			msg.local = local;
			return msg;
		}
		
		public function get chat():SimpleChat
		{
			return _chat;
		}
		
		public function set chat( value:SimpleChat ):void
		{
			_chat = value;
		}
		
		public function get time():Date
		{
			return _time;
		}
		
		public function set time( value:Date ):void
		{
			_time = value;
		}
		
		public function get body():String
		{
			return _body;
		}
		
		public function set body( value:String ):void
		{
			_body = value;
		}
		
		public function get nick():String
		{
			return _nick;
		}
		
		public function set nick( value:String ):void
		{
			_nick = value;
		}
		
		public function get from():UnescapedJID
		{
			return _from;
		}
		
		public function set from( value:UnescapedJID ):void
		{
			_from = value;
		}
		
		public function get id():String
		{
			return _id;
		}
		
		public function set id( value:String ):void
		{
			_id = value;
		}
	
	}

}